//
//  HonorTableCell.m
//  HomePage
//
//  Created by HanHaiDi on 13-8-21.
//  Copyright (c) 2013年 winston. All rights reserved.
//

#import "HonorTableCell.h"

#define AwardingUnits_Row_Capacity 24
#define FontHeight 20
#define TopSpace 20

@implementation HonorTableCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        UIView *tempView = [[[UIView alloc] init] autorelease];
        [self setBackgroundView:tempView];
        [self setBackgroundColor:[UIColor clearColor]];
        
        labelYear= [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
        labelYear.backgroundColor = [UIColor clearColor];
        labelYear.textAlignment = NSTextAlignmentCenter;
        labelYear.textColor = [UIColor colorWithRed:0.541 green:0.541 blue:0.541 alpha:1.0];
        labelYear.font = [UIFont fontWithName:@"Arial" size:18];
        [self addSubview:labelYear];
        [labelYear release];
        
        labelAwardingUnits= [[UITextView alloc] initWithFrame:CGRectMake(180, 0, 450, 40)];
        labelAwardingUnits.editable = NO;
        [labelAwardingUnits setScrollEnabled:NO];
        labelAwardingUnits.backgroundColor = [UIColor clearColor];
        labelAwardingUnits.textAlignment = NSTextAlignmentCenter;
        labelAwardingUnits.textColor = [UIColor colorWithRed:0.541 green:0.541 blue:0.541 alpha:1.0];
        labelAwardingUnits.font = [UIFont fontWithName:@"Arial" size:18];
        [self addSubview:labelAwardingUnits];
        [labelAwardingUnits release];
        
        labelPrizeName= [[UILabel alloc] initWithFrame:CGRectMake(683, 0, 220, 40)];
        labelPrizeName.backgroundColor = [UIColor clearColor];
        labelPrizeName.textAlignment = NSTextAlignmentCenter;
        labelPrizeName.textColor = [UIColor colorWithRed:0.541 green:0.541 blue:0.541 alpha:1.0];
        labelPrizeName.font = [UIFont fontWithName:@"Arial" size:18];
        [self addSubview:labelPrizeName];
        [labelPrizeName release];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void) loadData:(NSDictionary*)dicContent{
    [labelYear setText:[dicContent objectForKey:@"Year"]];
    
    [labelAwardingUnits setText:[dicContent objectForKey:@"AwardingUnits"]];
    [labelPrizeName setText:[dicContent objectForKey:@"PrizeName"]];
    
    NSString * awardingUnits = [dicContent objectForKey:@"AwardingUnits"];
    NSInteger rowCount = (awardingUnits.length / AwardingUnits_Row_Capacity) +1;
    [labelYear setFrame:CGRectMake(0, 0, 80, (rowCount*FontHeight)+TopSpace)];
    [labelAwardingUnits setFrame:CGRectMake(180, 0, 450, (rowCount*FontHeight)+TopSpace)];
    [labelPrizeName setFrame:CGRectMake(683, 0, 220, (rowCount*FontHeight)+TopSpace)];
}

@end
